function equals(a, b) {
    if (Array.isArray(a) && Array.isArray(b)) {
        if (a === b) {
            return true;
        }
        if (a.length == b.length) {
            for (let i = 0; i < a.length; i++) {
                if (a[i] !== b[i]) {
                    return false;
                }
            }
            return true;
        }
    }
    return false;
}
let array1 = [10, 20, 30, 40];
let array2 = [10, 20, 30, 40];
let array3 = [10, 20, 30, 50];
let array4 = [10, 20, 30, 40, 50];
console.log(array1 === array2); // false 
console.log(equals(array1, array2)); // true 
console.log(equals(array1, array3)); // false 
console.log(equals(array1, array4)); // false